﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class ClassSystem : MonoBehaviour {
    //public List<Trait>
    int back_iRank;

	// Use this for initialization
	void Start () {
        back_iRank = gameObject.GetComponent<UnitStatus>().m_unitData.ClassStatus.AssnStatus.iRank;
	}
	
	// Update is called once per frame
	void Update () {
        ExpUp();
	}

    void ExpUp()
    {
        switch (back_iRank)
        {
            case 0:
                RankUp(10);
                break;

            case 1:
                RankUp(20);
                break;

            case 2:
                RankUp(30);
                break;
        }
    }

    void RankUp(int iNeededExp)
    {
        if (gameObject.GetComponent<UnitStatus>().m_unitData.iExp >= iNeededExp)
        {
            gameObject.GetComponent<UnitStatus>().m_unitData.iExp -= iNeededExp;
            gameObject.GetComponent<UnitStatus>().m_unitData.ClassStatus.AssnStatus.iRank += 1;
            back_iRank = gameObject.GetComponent<UnitStatus>().m_unitData.ClassStatus.AssnStatus.iRank;
            ResourceMgr.GetInstance().CreateInGameText(gameObject, "LEVEL UP", new Color(58/255f, 39/255f, 24/255f));

            ResourceMgr.GetInstance().CreateSystemMsg(string.Format(xmlLoader.GetInstance().TextLoad(XML_INDEX.SYSTEM_MSG, "LevelUP"), gameObject.GetComponent<UnitStatus>().m_unitData.strLastName));
            //ObjFactory.AddPerk(gameObject, 0);
            gameObject.GetComponent<UnitStatus>().m_unitData.iTraitPoint += 1;
        }
    }
}
